package com.youdelu.stock.dao.actions.ChartKline.task;

import com.gree.shyunme.App;
import com.gree.shyunme.server.actions.ChartKline.ChKlineAction;
import com.gree.shyunme.server.actions.ChartKline.requestParam.ChKlineRequest;
import com.gree.shyunme.server.actions.ChartKline.respone.ChKlineRespone;
import com.gree.shyunme.server.network.async.AsyncTaskManager;
import com.gree.shyunme.server.network.http.HttpException;
import com.gree.shyunme.server.task.Task;

/**
* ${remark} 任务
* Created by youdelu on 2022-04-25 15:24:09.
*/
public class ChKlineTask extends Task {
    final static String TAG = com.gree.shyunme.server.actions.ChartKline.task.ChKlineTask.class.getSimpleName();
    @Override
    public Task doTask() {
		ChKlineRequest request = new ChKlineRequest();
        request.setIndicator("kline,pe,pb,ps,pcf,market_capital,agt,ggt,balance");//kline,pe,pb,ps,pcf,market_capital,agt,ggt,balance,
        request.setSymbol("SH600538");//SH600538,
        request.setPeriod("day");//day,5,   1m 1分，5m 5分，15m 15分  30m 30分 ，60m 60分 120m 120分 ，year 年 ,quarter 季 ，month 月，week 周，day天，
        request.setCount("-284");//-284,
        request.setType("before");//before,
        request.setBegin("1650947067441");//1650947067441,
        ChKlineAction action= new ChKlineAction(App.getApp());
        try {
                ChKlineRespone respone = action.get(request);
                if(respone.getError_code()==200){
                    //处理返回数据
                    set("respone",respone);
                }else{
                    setStatus(ERROR);
                    set("code",respone.getError_code());
                    setException(respone.getError_description());
                }
        } catch (HttpException e) {
            e.printStackTrace();
            setStatus(ERROR);
            int state = AsyncTaskManager.getErrorState(e);
            set("code", state);
            setException(AsyncTaskManager.getErrMsgByState(state));
        }
        return this;
    }
}